<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-tooltip/paper-tooltip.html">
<link rel="import" href="vz-projector-legend.html">
<link rel="import" href="styles.html">

<dom-module id="vz-projector-data-panel">
<template>
<style include="vz-projector-styles"></style>
<style>
.container {
  padding: 10px 20px 20px 20px;
}

input[type=file] {
  display: none;
}

.file-name {
  margin-right: 10px;
}

.dirs {
  color: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  font-size: 12px;
  margin: 15px 0;
  line-height: 20px;
}

.dir {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

paper-item {
  --paper-item-disabled: {
    border-bottom: 1px solid black;
    justify-content: center;
    font-size: 12px;
    line-height: normal;
    min-height: 0px;
  };
}

.item-details {
  margin-left: 5px;
  color: gray;
  font-size: 12px;
}

paper-dropdown-menu {
  width: 100%;
}

paper-dropdown-menu paper-item {
  justify-content: space-between;
}

.title {
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  color: black;
  display: flex;
  font-weight: 500;
  height: 59px;
  padding-left: 20px;
}

#upload-buttons {
  display: flex;
  justify-content: space-between;
}

#normalize-data-checkbox {
  margin: 10px 0;
}
</style>
<div class="title">DATA</div>
<div class="container">
  <!-- List of runs -->
  <template is="dom-if" if="[[_hasChoices(runNames)]]">
    <paper-dropdown-menu no-animations label="[[_getNumRunsLabel(runNames)]] found">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedRun}}">
        <template is="dom-repeat" items="[[runNames]]">
          <paper-item value="[[item]]" label="[[item]]">
            [[item]]
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
  </template>

  <template is="dom-if" if="[[tensorNames]]">
    <!-- List of tensors in checkpoint -->
    <paper-dropdown-menu no-animations label="[[_getNumTensorsLabel(tensorNames)]] found">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedTensor}}">
        <template is="dom-repeat" items="[[tensorNames]]">
          <paper-item value="[[item.name]]" label="[[item.name]]">
            [[item.name]]
            <span class="item-details">
              [[item.shape.0]]x[[item.shape.1]]
            </span>
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
  </template>
  <!-- Label by -->
  <template is="dom-if" if="[[_hasChoices(labelOptions)]]">
    <paper-dropdown-menu no-animations label="Label by">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedLabelOption}}">
        <template is="dom-repeat" items="[[labelOptions]]">
          <paper-item value="[[item]]" label="[[item]]">
            [[item]]
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
  </template>

  <!-- Color by -->
  <template is="dom-if" if="[[_hasChoices(colorOptions)]]">
    <paper-dropdown-menu id="colorby" no-animations label="Color by">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedColorOptionName}}">
        <template is="dom-repeat" items="[[colorOptions]]">
          <paper-item class$="[[getSeparatorClass(item.isSeparator)]]" value="[[item.name]]" label="[[item.name]]" disabled="[[item.isSeparator]]">
            [[item.name]]
            <span class="item-details">[[item.desc]]</span>
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
    <vz-projector-legend render-info="[[colorLegendRenderInfo]]"></vz-projector-legend>
  </template>
  <paper-checkbox id="normalize-data-checkbox" checked="{{normalizeData}}">
    Sphereize data
    <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
    <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds>
      The data is normalized by shifting each point by the centroid and making
      it unit norm.
    </paper-tooltip>
  </paper-checkbox>
  <!-- Upload buttons -->
  <div id="upload-buttons">
    <!-- Upload data -->
    <div>
      <button id="upload" title="Upload a TSV file" class="ink-button">Upload data</button>
      <input type="file" id="file" name="file"/>
    </div>
    <!-- Upload metadata -->
    <div>
      <button id="upload-metadata" title="Upload a TSV metadata file" class="ink-button">Upload Metadata</button>
      <input type="file" id="file-metadata" name="file-metadata"/>
    </div>
  </div>
    <div class="dirs">
    <div class="dir">Checkpoint: <span id="checkpoint-file"></span></div>
    <div class="dir">Metadata: <span id="metadata-file"></span></div>
  </div>
</div>
<!-- Closing global template -->
</template>
</dom-module>
